Add additional 'new' method to Repo
authorFelix Krull <f_krull@gmx.de>
Sat, 29 Sep 2018 16:21:36 +0000 (18:21 +0200)
committerColin Walters <walters@verbum.org>
Fri, 6 May 2022 16:53:53 +0000 (12:53 -0400)
rust-bindings/rust/libostree/src/lib.rs
rust-bindings/rust/libostree/src/prelude.rs [deleted file]
rust-bindings/rust/libostree/src/repo.rs [new file with mode: 0644]
rust-bindings/rust/sample/src/main.rs

index 2e7accdc35cd5ed291cd7a41742bbd00e8b8652f..f473ca8065ad0cfbee0b7c4dad8fda16b545a34b 100644 (file)
@@ -13,6 +13,10 @@ use glib::Error;
 mod auto;
 pub use auto::*;
 
+mod repo;
+
 // public modules
-pub mod prelude;
-pub use prelude::*;
+pub mod prelude {
+    pub use auto::traits::*;
+    pub use repo::RepoExtManual;
+}
diff --git a/rust-bindings/rust/libostree/src/prelude.rs b/rust-bindings/rust/libostree/src/prelude.rs
deleted file mode 100644 (file)
index a289db0..0000000
+++ /dev/null
@@ -1 +0,0 @@
-pub use traits::*;
diff --git a/rust-bindings/rust/libostree/src/repo.rs b/rust-bindings/rust/libostree/src/repo.rs
new file mode 100644 (file)
index 0000000..add41b2
--- /dev/null
@@ -0,0 +1,15 @@
+use auto::Repo;
+
+use gio;
+use glib;
+use glib::IsA;
+
+pub trait RepoExtManual {
+    fn new_for_str(path: &str) -> Repo;
+}
+
+impl<O: IsA<Repo> + IsA<glib::Object> + Clone + 'static> RepoExtManual for O {
+    fn new_for_str(path: &str) -> Repo {
+        Repo::new(&gio::File::new_for_path(path))
+    }
+}
index 73443e8d256c391a825f9353a565657657e1a457..6735fc0141fe639a01e9bd948c18fd3ada7446f4 100644 (file)
@@ -1,16 +1,11 @@
 extern crate gio;
 extern crate libostree;
 
-use gio::prelude::*;
 use libostree::prelude::*;
 
 fn main() {
-    let repo = libostree::Repo::new(&gio::File::new_for_path("test-repo"));
+    let repo = libostree::Repo::new_for_str("test-repo");
 
     let result = repo.create(libostree::RepoMode::Archive, Option::None);
-
     result.expect("we did not expect this to fail :O");
-
-    let path = repo.get_path();
-    println!("path: {}", path.unwrap().get_path().unwrap().to_str().unwrap());
 }